/**
 * Created With IntelliJ IDEA
 * Description:leetcode：100. 相同的树
 * <a href="https://leetcode.cn/problems/same-tree/">...</a>
 * User: DELL
 * Data: 2023-01-14
 * Time: 11:38
 */

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int val) {
        this.val = val;
    }
 }
public class Solution {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        }
        if (p == null || q == null || p.val != q.val) {
            return false;
        }
        return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
    }
}
